home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / 21ripl.zip / IBMLS.ZIP / RPLSETD.CMD < prev   
OS/2 REXX Batch file  |  1993-03-13  |  54KB  |  1,452 lines

  1. /* RPLSETD.CMD - REXX program to convert an existing OS/2 Remote IPL client  */
  2. /*               to use the 32-bit VGA and XGA device drivers or the 16-bit  */
  3. /*               8514 device driver.                                         */
  4. /*                                                                           */
  5. /*    Copyright: (C) Copyright IBM Corp. 1993                                */
  6. /*                                                                           */
  7. /*    Note 1: All the variables are global to all subroutines.               */
  8. /*                                                                           */
  9. /*    Note 2: All NLS message strings are centrally located in the           */
  10. /*            subroutine Initialize_NLS_Messages at the end of this          */
  11. /*            rexx procedure.                                                */
  12.  
  13. driver = ''
  14. client = ''
  15. logfile = ''
  16. Rspfile = ''
  17. os2csdlevel = ''
  18. currentOS2 = 'OS2.20'
  19. newOS2 = 'OS2.21'
  20. CRLF = '0A0D'X
  21. ERROR_INFO_type = 1
  22. SYNTAX_type = 2
  23. changeOS2 = 0
  24. basedevflag = 1
  25. clientlist.0 = 0
  26. msgdata = ''
  27.  
  28. /* initialize NLS error and informational message strings */
  29. Call Initialize_NLS_Messages ERROR_INFO_type
  30.  
  31. Parse Arg  parm.1 parm.2 parm.3 parm.4 parm.5 parm.6 .
  32. /* Check for help request (parm.1 = ? or '') */
  33. If parm.1 = '?' | parm.1 = '' Then Call Syntax_Help
  34.  
  35. Call Process_Input_Parameters
  36. If result <> 0 Then Call Error_Exit
  37.  
  38. If Rspfile <> '' Then Do
  39.    Call Read_Rspfile
  40.    If result <> 0 Then Do
  41.       Say errprefix || message.1 Rspfile || CRLF || message.2
  42.       exit result
  43.    end
  44. end
  45.  
  46. /* if logfile specified, delete old log file (if it exists) & log header */
  47. If Logfile <> '' Then Do
  48.    Call Delete_File Logfile
  49.    msgdata = 'RPLSETD ' || message.3 || Date('U')  Time()
  50.    Call Lineout Logfile, msgdata
  51.    If result <> 0 Then Do
  52.       Say message.4 || Logfile
  53.       exit 4
  54.    end
  55.    Call Lineout Logfile, ' '
  56. end
  57.  
  58. /* were required parameters  entered ?*/
  59. If driver = '' | clientlist.0 = 0 Then Call Syntax_Help
  60.  
  61. Call Validate_Display_DriverID
  62. If result <> 0 Then Call Error_Exit
  63.  
  64. ddbootdrv = ''
  65. dd_data.0 = 0
  66.  
  67. /* build list of directories in RPL\IBMCOM to process */
  68. lanlist.0 = 6
  69. lanlist.1 = 'TOKENRNG'
  70. lanlist.2 = 'ETHERNET'
  71. lanlist.3 = 'PCNETA'
  72. lanlist.4 = 'PCNET'
  73. lanlist.5 = 'ELNKII'
  74. lanlist.6 = 'ELNKMC'
  75.  
  76. Call Determine_RIPL_Directory
  77. If result <> 0 Then Call Error_Exit
  78.  
  79. /* get LAN Server version */
  80. Call Get_LAN_Server_Version
  81. if result <> 0 Then Exit
  82.  
  83. /* get version of OS/2 in target OS/2 RIPL directory */
  84. Call Get_RIPL_OS2_Version
  85. if result <> 0 Then Call Error_Exit
  86.  
  87. /* determine if desired device driver is installed */
  88. If changeOS2 = 1 Then ddpath = rpldir'\'newOS2'\OS2\DLL\'
  89. else  ddpath = rpldir'\'currentOS2'\OS2\DLL\'
  90. filename = ddpath||driver||'.DLL'
  91. if File_Exist(filename) = 0 Then Do
  92.    ddpath = substr(ddpath, 1, length(ddpath) - 1)
  93.    msgdata = errprefix || message.5
  94.    Call Display_Log_Msg msgdata, driver, dpath
  95.    Call Error_Exit
  96. end
  97.  
  98. /* If OS/2 2.1 is in RIPL tree, check to see if 2.1 migration has been run. */
  99. If version21 = 1 & File_Exist(rpldir'\RPLMIG21.$$$') = 0 Then Do
  100.    msgdata = errprefix || message.23
  101.    Call Display_Log_Msg msgdata, ''
  102.    Call Error_Exit
  103. end
  104.  
  105. do clnum = 1 to clientlist.0
  106.    /* update each client in list */
  107.    client = clientlist.clnum
  108.    Call Update_Client_Files
  109. end
  110.  
  111. If Logfile <> '' Then Call Lineout Logfile
  112. exit
  113. /* end of main routine */
  114.  
  115.  
  116. /*************** Start of subroutines ***************************/
  117.  
  118.  
  119. /* Subroutine Error_Exit */
  120. /* This subroutine cleans up on an error exit. */
  121. Error_Exit:
  122.    If Logfile <> '' Then Do
  123.       Call Lineout Logfile
  124.       Say message.7 || Logfile
  125.    end
  126.    exit 4
  127.  
  128.  
  129. /* Subroutine Get_LAN_Server_Version */
  130. /* This subroutine determines the version of LAN Server installed on  */
  131. /* the Remote IPL server. */
  132. Get_LAN_Server_Version:
  133.    /* Read the first 60 bytes of SYSLEVEL.SRV and check the current server level*/
  134.    filename = lanpath'\SYSLEVEL.SRV'
  135.    syslevel = ''
  136.    Do i = 1 to 60
  137.       syslevel = syslevel || charin(filename)
  138.    end
  139.    Call Charout filename
  140.    verp = pos('IP', syslevel)
  141.    If verp <> 0 Then LS_version = substr(syslevel, verp+3, 4)
  142.    If LS_version = '' Then Do
  143.       msgdata = errprefix || message.8
  144.       Call Display_Log_Msg msgdata, ''
  145.       return 4
  146.    end
  147.    return 0
  148.  
  149.  
  150.  
  151. Get_RIPL_OS2_Version:
  152.    /* Read the first 60 bytes of RIPL SYSLEVEL.OS2 and get the current */
  153.    /* OS/2 CSD level and version id */
  154.    If changeOS2 = 1 Then spath = rpldir'\'newOS2
  155.    else  spath = rpldir'\'currentOS2
  156.    filename = spath'\OS2\INSTALL\SYSLEVEL.OS2'
  157.    syslevel = ''
  158.    If File_Exist(filename) = 1 Then Do
  159.       Do i = 1 to 60
  160.          syslevel = syslevel || charin(filename)
  161.       end
  162.       Call Charout filename
  163.       verp = pos('XR', syslevel)
  164.    end
  165.    else verp = 0
  166.  
  167.    If verp <> 0 Then os2csdlevel = substr(syslevel, verp, 8)
  168.    else os2csdlevel = unknown
  169.    If os2csdlevel = unknown | substr(os2csdlevel, 4, 4) = '2000' Then Do
  170.       msgdata = errprefix || message.9
  171.       Call Display_Log_Msg msgdata, spath, os2csdlevel
  172.       return 4
  173.    end
  174.  
  175.    /* the following is to differentiate between 2.0+SP, 2.00.1, and 2.1 */
  176.    version21 = 0
  177.    If substr(os2csdlevel, 4, 4) = '6055' Then basedevflag = 1
  178.    else If substr(os2csdlevel, 4, 4) = '2010' & substr(syslevel, 41, 1) = '20'x  Then basedevflag = 0
  179.         else Do
  180.            /* 2.1 */
  181.            basedevflag = 1
  182.            version21 = 1
  183.         end
  184.    return 0
  185.  
  186.  
  187. /* Subroutine Update_Client_Files */
  188. /* This subroutine calls the subroutines to update each client file. */
  189. Update_Client_Files:
  190.    /* update the client copy of OS2INI.20 */
  191.    Call Update_Client_Ini
  192.    If result = 0 Then Do
  193.       msgdata = client || message.10
  194.       Call Display_Log_Msg msgdata, client
  195.  
  196.       /* update the client CONFIG.20 file.  If the client is DEFALT20, then */
  197.       /* there is special processing to update each of the master CONFIG.20 */
  198.       /* files in the RPL\IBMCOM tree. */
  199.       if client = 'DEFALT20' Then Do
  200.          /* for DEFALT20 update each of the lantype CONFIG.20 and CONFIGRI.20 files */
  201.          Do lli = 1 to lanlist.0
  202.             lantype = lanlist.lli
  203.             configfilename = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  204.             If File_Exist(configfilename) <> 0 Then Do
  205.                /* a CONFIG.20 file is present, update it */
  206.                Call Update_Client_Config_20
  207.                If result = 0 Then Do
  208.                   msgdata = lantype || message.11
  209.                   Call Display_Log_Msg msgdata, ''
  210.                end
  211.                else Do
  212.                   msgdata = errprefix || client || lantype || message.12
  213.                   Call Display_Log_Msg msgdata, ''
  214.                end
  215.             end
  216.  
  217.             configfilename = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  218.             If File_Exist(configfilename) <> 0 Then Do
  219.                /* a CONFIGRI.20 file is present, update it */
  220.                Call Update_Client_Configri_20
  221.                If result = 0 Then Do
  222.                   msgdata = lantype || message.25
  223.                   Call Display_Log_Msg msgdata, ''
  224.                end
  225.                else Do
  226.                   msgdata = errprefix || client || lantype || message.26
  227.                   Call Display_Log_Msg msgdata, ''
  228.                end
  229.             end
  230.          end
  231.       end
  232.       else Do
  233.          /* not the DEFALT20 client */
  234.          Call Update_Client_Config_20
  235.          If result = 0 Then Do
  236.             msgdata = client || message.11
  237.             Call Display_Log_Msg msgdata, ''
  238.          end
  239.          else Do
  240.             msgdata = errprefix || client || message.12
  241.             Call Display_Log_Msg msgdata, ''
  242.          end
  243.  
  244.          Call Update_Client_Configri_20
  245.          If result = 0 Then Do
  246.             msgdata = client || message.25
  247.             Call Display_Log_Msg msgdata, ''
  248.          end
  249.          else Do
  250.             msgdata = errprefix || client || message.26
  251.             Call Display_Log_Msg msgdata, ''
  252.          end
  253.       end
  254.  
  255.       /* Update the client.FIT file */
  256.       Call Update_Client_Fit
  257.       If result = 0 Then Do
  258.          msgdata = client||message.13
  259.          Call Display_Log_Msg msgdata, ''
  260.       end
  261.       else Do
  262.          /* error updating client fit */
  263.          msgdata = errprefix || client||message.14
  264.          Call Display_Log_Msg msgdata, ''
  265.       end
  266.  
  267.       If client <> 'DEFALT20' Then Do
  268.          /* not DEFALT20, check to see if RPL.MAP needs to be updated */
  269.          If changeOS2 = 1 Then Do
  270.             /* update workstation record in RPL.MAP */
  271.             Call Update_Workstation_Record
  272.             If result = 0 Then Do
  273.                msgdata = client||message.27
  274.                Call Display_Log_Msg msgdata, ''
  275.             end
  276.             else Do
  277.                /* error updating workstation record */
  278.                msgdata = errprefix||client||message.28
  279.                Call Display_Log_Msg msgdata, ''
  280.             end
  281.          end
  282.       end
  283.    end
  284.    else Do
  285.       /* INI update failed, skip CONFIG.20, FIT, & RPL.MAP update */
  286.       msgdata = errprefix || client || message.15 || client '.'
  287.       Call Display_Log_Msg msgdata, ''
  288.    end
  289.  
  290.    msgdata = '  '
  291.    Call Display_Log_Msg msgdata, ''
  292.    return 0
  293.  
  294.  
  295.  
  296. /* Subroutine Update_Client_Ini */
  297. /* This subroutine updates the OS2INI.20 file for a client workstation */
  298. /* to add the required profile data to support the specified device driver. */
  299. Update_Client_Ini:
  300.  
  301.    rc = 0
  302.    If newOS2 = 'OS2.21' Then Do
  303.       /* check to see if OS2INI.21 exists */
  304.       ininame = rpldir'USER\'client'\OS2\'
  305.       If File_Exist(ininame'OS2INI.21') = 1 Then Do
  306.          /* copy 21 filenames into 20 filenames */
  307.          '@ATTRIB -r 'ininame'OS2*.20'
  308.          '@ATTRIB -r 'ininame'OS2*.21'
  309.          '@COPY 'ininame'OS2INI.21 ' ininame'OS2INI.20 1>nul 2>nul'
  310.          '@COPY 'ininame'OS2SYINI.21 ' ininame'OS2SYINI.20 1>nul 2>nul'
  311.          Call Delete_File ininame'OS2INI.21B'
  312.          Call Delete_File ininame'OS2SYINI.21B'
  313.       end
  314.    end
  315.  
  316.    /* build fully qualified path name for OS2INI.20 */
  317.    ininame = rpldir'USER\'client'\OS2\OS2INI.20'
  318.    /* Execute RPLRXUTL to update client copy of OS2.INI (OS2INI.20) */
  319.    cmdline = '@RPLRXUTL.EXE /D:'driver ' /C:'ininame '1>nul'
  320.    address CMD cmdline
  321.    return rc
  322.  
  323.  
  324.  
  325.  
  326. /* Subroutine Update_Client_Fit */
  327. /* This subroutine creates a new client.FIT by making the following */
  328. /* changes to the original FIT: */
  329. /*   - Comment out the DISPLAY.DLL entries. */
  330. /*   - Enables the correct .FON entries for the specified display driver. */
  331. /*   - If requested, changes the target OS2 root directory. */
  332. Update_Client_Fit:
  333.  
  334.    /* build fully qualified path names for client.??? */
  335.    fitname = rpldir'\FITS\'client'.FIT'
  336.    tmpfitname = rpldir'\FITS\'client'.TMP'
  337.    bakfitname = rpldir'\FITS\'client'.BAK'
  338.    /* Call SysFileDelete tmpfitname */
  339.    Call Delete_File tmpfitname
  340.    Call Delete_File bakfitname
  341.  
  342.    If File_Exist(fitname) Then Do
  343.       /* client.FIT does exists, build a new FIT */
  344.       os2verflag = 0
  345.       do until lines(fitname) = 0
  346.          data = translate(linein(fitname))
  347.          If data <> '' & substr(data, 1, 2) <> '\\' Then Do
  348.             /* not a null line or a UNC line, check line */
  349.             datap = pos(':\OS2\DLL\DISPLAY.DLL', data)
  350.             if datap <> 0 Then Do
  351.                if substr(data,1,1) <> ';' Then Do
  352.                   /* comment out DISPLAY.DLL entry */
  353.                   newdata = ';'data
  354.                   data = newdata
  355.                end
  356.             end
  357.             else Do
  358.                /* check for .FON entry and enable/disable the entry */
  359.                /* depending on the driver type */
  360.                helvp = 0
  361.                courp = 0
  362.                timesp = 0
  363.                helvp = pos(':\OS2\DLL\HELV.FON', data)
  364.                If helvp = 0 Then Do
  365.                   courp = pos(':\OS2\DLL\COURIER.FON',data)
  366.                   If courp = 0 Then Do
  367.                      timesp = pos(':\OS2\DLL\TIMES.FON',data)
  368.                   end
  369.                end
  370.                If helvp <> 0 | courp <> 0 | timesp <> 0 Then Do
  371.                  datal = length(data)
  372.                  If driver = 'IBMVGA32' | driver = 'IBMVGA' Then Do
  373.                     If substr(data, datal-2, 3) <> 'VGA' Then Do
  374.                        If substr(data, 1,1) <> ';' Then Do
  375.                           /* disable non-VGA .FON entry */
  376.                           newdata = ';'data
  377.                           data = newdata
  378.                        end
  379.                     end
  380.                     else If substr(data, 1, 1) = ';' Then Do
  381.                        /* enable VGA .FON entry */
  382.                        data = substr(data, 2)
  383.                     end
  384.                  end
  385.                  else If driver = 'IBMXGA32' | driver = 'IBM8514' Then Do
  386.                     If substr(data, datal-2, 3) <> 'BGA' Then Do
  387.                        If substr(data, 1, 1) <> ';' Then Do
  388.                           /* disable non-XGA/8514 .FON entry */
  389.                           newdata = ';'data
  390.                           data = newdata
  391.                        end
  392.                     end
  393.                     else If substr(data, 1, 1) = ';' Then Do
  394.                        /* enable XGA/8514 .FON entry */
  395.                        data = substr(data, 2)
  396.                     end
  397.                  end
  398.                end
  399.             end
  400.  
  401.             /* check for possible operating system change */
  402.             if changeOS2 = 1 Then Do
  403.                If substr(data, 1, 2) = '; ' Then srvfname = word(data, 3)
  404.                else srvfname = word(data, 2)
  405.                os2p = pos(currentOS2'\', srvfname)
  406.                if os2p <> 0 Then Do
  407.                   /* old OS2 entry found, update it */
  408.                   os2p = pos(currentOS2, data, length(word(data,1))+1)
  409.                   newdata = substr(data, 1, os2p-1)
  410.                   newdata = newdata || newOS2
  411.                   newdata = newdata || substr(data, os2p+length(currentOS2))
  412.                   data = newdata
  413.                end
  414.             end
  415.          end
  416.          /* pick up boot drive id from OS2KRNL entry */
  417.          os2p = pos(':\OS2KRNL ', translate(data))
  418.          If os2p <> 0 Then bootdrv = substr(data, os2p-1, 1)
  419.  
  420.          /* check for OS2VER reference, set flag if found */
  421.          os2p = pos(':\OS2VER ', translate(data))
  422.          If os2p <> 0 Then os2verflag = 1
  423.  
  424.          /* write data record to new FIT */
  425.          Call Lineout tmpfitname, data
  426.       end
  427.  
  428.       /* does os2ver statment need to be added? */
  429.       If os2verflag = 0 Then Do
  430.          /* add os2ver statement to end of file */
  431.          Call lineout tmpfitname, '  '
  432.          data = bootdrv':\OS2VER    'newOS2'\OS2VER'
  433.          Call Lineout tmpfitname, data
  434.       end
  435.  
  436.       Call Lineout tmpfitname   /* close file */
  437.       Call Lineout fitname      /* close file */
  438.  
  439.       /* rename original client.FIT */
  440.       cmdstr = '@rename 'fitname' 'client'.BAK'
  441.       address CMD cmdstr
  442.       if rc = 0 Then Do
  443.          /* rename client.TMP to be client.FIT */
  444.          cmdstr = '@rename 'tmpfitname' 'client'.FIT'
  445.          address CMD cmdstr
  446.          if rc = 0 Then Do
  447.             /* delete orginal client.FIT */
  448.             /* Call SysFileDelete bakfitname */
  449.             cmdstr = '@DEL 'bakfitname
  450.             address CMD cmdstr
  451.          end
  452.          else Do
  453.             /* rename error, try to restore original */
  454.             cmdstr = '@rename 'bakfitname'  'client'.FIT'
  455.             address CMD cmdstr
  456.       end
  457.    end
  458.    else return 4
  459.    return 0
  460.  
  461.  
  462.  
  463. /* Subroutine Update_Client_Config_20 */
  464. /* This subroutine creates a new CONFIG.20 for the client that has the */
  465. /* appropriate display device drivers enabled. */
  466. Update_Client_Config_20:
  467.  
  468.    /* if LS 2.0 file, convert it to new format */
  469.    If LS_version = '6000' Then Do
  470.       Call Update_LS20_Config_20
  471.       If result <> 0 Then Do
  472.          msgdata = errprefix || message.16
  473.          Call Display_Log_Msg msgdata, rpldir, lantype
  474.          return 4
  475.       end
  476.    end
  477.  
  478.    /* build fully qualified path names for client CONFIG.20 */
  479.    If client = 'DEFALT20' Then Do
  480.       /* DEFALT20 is special case, it must be called for each lantype */
  481.       configname = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  482.       tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20T'
  483.       bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20B'
  484.    end
  485.    else Do
  486.       configname = rpldir'\MACHINES\'client'\CONFIG.20'
  487.       tmpconfigname = rpldir'\MACHINES\'client'\CONFIG.20T'
  488.       bakconfigname = rpldir'\MACHINES\'client'\CONFIG.20B'
  489.    end
  490.    /* Call SysFileDelete tmpconfigname */
  491.    Call Delete_File tmpconfigname
  492.    Call Delete_File bakconfigname
  493.  
  494.    If File_Exist(configname) Then Do
  495.       /* copy records to first DEVINFO (XGA) */
  496.       flag = 0
  497.       do until lines(configname) = 0
  498.          data = linein(configname)
  499.          ucdata = translate(data)
  500.          If pos('DEVINFO=', ucdata) <> 0 Then Leave
  501.          xgacomp = pos('ing 6 state', data)
  502.          If xgacomp <> 0 & driver = 'IBMXGA32' Then Do
  503.             /* update XGA comment statement */
  504.             newdata = substr(data, 1, xgacomp+3)||'7'||substr(data, xgacomp+5)
  505.             data = newdata
  506.          end
  507.          else Do
  508.             If version21 = 1 Then Do
  509.                /* version 2.1 */
  510.                /* check for AUTOSTART statement */
  511.                If pos('AUTOSTART=', ucdata) <> 0 Then Do
  512.                   If pos('CONNECTIONS', ucdata) = 0 Then data = data || ',CONNECTIONS'
  513.                end
  514.                else Do
  515.                   /* check for SHELL statement */
  516.                   pv = pos('SHELL=', ucdata)
  517.                   If pv <> 0 Then Do
  518.                      pv = pos('/P', ucdata)
  519.                      If pv <> 0 Then data = substr(data, 1, pv-1)
  520.                   end
  521.                end
  522.             end
  523.             If version21 = 1 | basedevflag = 0 Then Do
  524.                /* version 2.1 or 2.00.1 */
  525.                /* check for EPATH statement */
  526.                pv = pos('EPATH=', ucdata)
  527.                If pv <> 0 Then Do
  528.                   /* replace with EPMPATH */
  529.                   newdata = substr(data, 1, pv-1) || 'EPMPATH' || substr(data, pv+5)
  530.                   data = newdata
  531.                end
  532.             end
  533.          end
  534.          Call Lineout tmpconfigname, data
  535.       end
  536.  
  537.       /* process XGA statements */
  538.       xgasysflag = 0
  539.       position = pos(':\OS2\', ucdata)
  540.       bootdrv2 = substr(data, position-1, 1)
  541.       vgap = pos(',BGA,', ucdata)
  542.       If vgap <> 0 Then Do
  543.          newdata = substr(data, 1, vgap) || 'VGA' || substr(data, vgap+4)
  544.          data = newdata
  545.       end
  546.       flag = 0
  547.       Do while flag = 0
  548.          If driver = 'IBMXGA32' Then Do
  549.             If translate(substr(data, 1, 4)) = 'REM ' Then Do
  550.                data = substr(data, 5)
  551.                ucdata = translate(data)
  552.             end
  553.             If xgasysflag = 0 Then Do
  554.                If pos('XGA.SYS', ucdata) <> 0 Then Do
  555.                   /* replace XGA.SYS statement with version appropriate with */
  556.                   /* current value of basedevflag. */
  557.                   If basedevflag = 0 Then newdata = 'DEVICE='bootdrv2':\OS2\XGA.SYS'
  558.                   else newdata = 'BASEDEV=XGA.SYS'
  559.                   data = newdata
  560.                   xgasysflag = 1
  561.                end
  562.             end
  563.             if pos('\OS2\MDOS\VVGA.SYS', ucdata) <> 0 Then Do
  564.                If xgasysflag = 0 Then Do
  565.                   /* insert the XGA.SYS record */
  566.                   If basedevflag = 0 Then newdata = 'DEVICE='bootdrv2':\OS2\XGA.SYS'
  567.                   else newdata = 'BASEDEV=XGA.SYS'
  568.                   Call Lineout tmpconfigname, newdata
  569.                   xgasysflag = 1
  570.                end
  571.             end
  572.          end
  573.          else Do
  574.             /* make sure records are REMed out */
  575.             if substr(ucdata, 1, 4) <> 'REM ' Then Do
  576.                newdata = 'REM '||data
  577.                data = newdata
  578.             end
  579.             If pos('XGA.SYS', ucdata) <> 0 Then Do
  580.                /* replace XGA.SYS statement with version appropriate with */
  581.                /* current value of basedevflag. */
  582.                If basedevflag = 0 Then newdata = 'REM DEVICE='bootdrv2':\OS2\XGA.SYS'
  583.                else newdata = 'REM BASEDEV=XGA.SYS'
  584.                data = newdata
  585.                xgasysflag = 1
  586.             end
  587.             else if pos('\OS2\MDOS\VVGA.SYS', ucdata) <> 0 Then Do
  588.                If xgasysflag = 0 Then Do
  589.                   /* insert the XGA.SYS record */
  590.                   If basedevflag = 0 Then newdata = 'REM DEVICE='bootdrv2':\OS2\XGA.SYS'
  591.                   else newdata = 'REM BASEDEV=XGA.SYS'
  592.                   Call Lineout tmpconfigname, newdata
  593.                end
  594.             end
  595.          end
  596.          Call lineout tmpconfigname, data
  597.          if pos('SET VIO_XGA=', ucdata) <> 0 Then flag = 1
  598.          else Do
  599.             data = linein(configname)
  600.             ucdata = translate(data)
  601.          end
  602.       end
  603.  
  604.       /* copy records to next DEVINFO (8514) */
  605.       flag = 0
  606.       do until lines(configname) = 0
  607.          data = linein(configname)
  608.          ucdata = translate(data)
  609.          If pos('DEVINFO=', ucdata) <> 0 Then Leave
  610.          Call Lineout tmpconfigname, data
  611.       end
  612.  
  613.       /* process 8514 statements */
  614.       flag = 0
  615.       Do while flag = 0
  616.          If driver = 'IBM8514' Then Do
  617.             If translate(substr(data, 1, 4)) = 'REM ' Then Do
  618.                data = substr(data, 5)
  619.             end
  620.          end
  621.          else Do
  622.             /* make sure records are REMed out */
  623.             if substr(ucdata, 1, 4) <> 'REM ' Then Do
  624.                newdata = 'REM '||data
  625.                data = newdata
  626.             end
  627.          end
  628.          Call lineout tmpconfigname, data
  629.          if pos('\V8514A.SYS', ucdata) <> 0 Then flag = 1
  630.          else Do
  631.             data = linein(configname)
  632.             ucdata = translate(data)
  633.          end
  634.       end
  635.  
  636.       /* copy records to the VGA DEVINFO */
  637.       do until lines(configname) = 0
  638.          data = linein(configname)
  639.          ucdata = translate(data)
  640.          If pos('DEVINFO=SCR,VGA', ucdata) <> 0 Then Leave
  641.          Call Lineout tmpconfigname, data
  642.       end
  643.       newdata = ''
  644.  
  645.       /* process VGA statements */
  646.       flag = 0
  647.       Do while flag = 0
  648.          If driver = 'IBMVGA' | driver = 'IBMVGA32' Then Do
  649.             If substr(ucdata, 1, 4) = 'REM ' Then Do
  650.                data = substr(data, 5)
  651.             end
  652.          end
  653.          else Do
  654.             /* make sure records are REMed out */
  655.             if substr(ucdata, 1, 4) <> 'REM ' Then Do
  656.                newdata = 'REM '||data
  657.                data = newdata
  658.             end
  659.          end
  660.          Call lineout tmpconfigname, data
  661.          if pos('\VVGA.SYS', ucdata) <> 0 Then flag = 1
  662.          else Do
  663.             data = linein(configname)
  664.             ucdata = translate(data)
  665.          end
  666.       end
  667.  
  668.       /* copy remaining records */
  669.       ipfkeys = 0
  670.       faxpm = 0
  671.       do until lines(configname) = 0
  672.          data = linein(configname)
  673.          ucdata = translate(data)
  674.          If pos('IPF_KEYS=', ucdata) <> 0 Then ipfkeys = 1
  675.          If pos('FAXPM=', ucdata) <> 0 Then faxpm = 1
  676.          Call Lineout tmpconfigname, data
  677.       end
  678.  
  679.       If ipfkeys = 0 Then Do
  680.          If basedevflag = 0 | version21 = 1 Then Do
  681.             /* Add 2.00.1 and 2.1 statement */
  682.             Call Lineout tmpconfigname,'SET IPF_KEYS=SBCS'
  683.          end
  684.       end
  685.  
  686.       If faxpm = 0 Then Do
  687.          If version21 = 1 Then Do
  688.             /* Add 2.1 statement */
  689.             Call Lineout tmpconfigname,'SET FAXPM='bootdrv2':\OS2\APPS'
  690.          end
  691.       end
  692.  
  693.       Call Lineout tmpconfigname   /* close file */
  694.       Call Lineout configname      /* close file */
  695.  
  696.       /* rename original CONFIG.20 */
  697.       cmdstr = '@rename 'configname' CONFIG.20B'
  698.       address CMD cmdstr
  699.       if rc = 0 Then Do
  700.          /* rename CONFIG.20T to be CONFIG.20 */
  701.          cmdstr = '@rename 'tmpconfigname' CONFIG.20'
  702.          address CMD cmdstr
  703.          if rc = 0 Then Do
  704.             /* delete orginal CONFIG.20 */
  705.             /* Call SysFileDelete bakconfigname */
  706.             cmdstr = '@DEL 'bakconfigname
  707.             address CMD cmdstr
  708.          end
  709.          else Do
  710.             /* rename error, try to restore original */
  711.             cmdstr = '@rename 'bakconfigname' CONFIG.20'
  712.             address CMD cmdstr
  713.          end
  714.       end
  715.    end
  716.    else return 4   /* file not found */
  717.    return 0
  718.  
  719.  
  720. /* Subroutine Update_Client_Configri_20 */
  721. /* This subroutine creates a new CONFIGRI.20 for the client that has the */
  722. /* DRIVER=x:\OS2\TESTCFG.SYS statement added to it */
  723. Update_Client_Configri_20:
  724.  
  725.    /* build fully qualified path names for client CONFIGRI.20 */
  726.    If client = 'DEFALT20' Then Do
  727.       /* DEFALT20 is special case, it must be called for each lantype */
  728.       configname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20'
  729.       tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20T'
  730.       bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIGRI.20B'
  731.    end
  732.    else Do
  733.       configname = rpldir'\MACHINES\'client'\CONFIGRI.20'
  734.       tmpconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20T'
  735.       bakconfigname = rpldir'\MACHINES\'client'\CONFIGRI.20B'
  736.    end
  737.    /* Call SysFileDelete tmpconfigname */
  738.    Call Delete_File tmpconfigname
  739.    Call Delete_File bakconfigname
  740.  
  741.    bootdrv = 'Z'
  742.    If File_Exist(configname) Then Do
  743.       /* copy records looking for TESTCFG.SYS statement */
  744.       flag = 0
  745.       do until lines(configname) = 0
  746.          data = linein(configname)
  747.          ucdata = translate(data)
  748.          dpos = pos('SET PATH=', ucdata)
  749.          if dpos <> 0 Then Do
  750.             /* get bootdrive id from SET PATH statement */
  751.             dpos = pos(':\OS2;', ucdata)
  752.             if dpos <> 0 Then bootdrv = substr(ucdata, dpos-1, 1)
  753.          end
  754.          dpos = pos('DEVICE=', ucdata)
  755.          If dpos <> 0 Then Do
  756.             If pos('\OS2\TESTCFG.SYS', ucdata, dpos+7) <> 0 Then Do
  757.                /* DEVICE statement already present */
  758.                If word(ucdata, 1) = 'REM' Then Do
  759.                   /* statement REMed out, un-REM it */
  760.                   newdata = substr(data, dpos)
  761.                   data = newdata
  762.                end
  763.                flag = 1
  764.             end
  765.          end
  766.          Call lineout tmpconfigname, data
  767.       end
  768.       If flag = 0 Then Do
  769.          /* add DEVICE statement to end of file */
  770.          Call lineout tmpconfigname, 'DEVICE='bootdrv':\OS2\TESTCFG.SYS'
  771.       end
  772.  
  773.       Call Lineout tmpconfigname   /* close file */
  774.       Call Lineout configname      /* close file */
  775.  
  776.       /* rename original CONFIGRI.20 */
  777.       cmdstr = '@rename 'configname' CONFIGRI.20B'
  778.       address CMD cmdstr
  779.       if rc = 0 Then Do
  780.          /* rename CONFIGRI.20T to be CONFIGRI.20 */
  781.          cmdstr = '@rename 'tmpconfigname' CONFIGRI.20'
  782.          address CMD cmdstr
  783.          if rc = 0 Then Do
  784.             /* delete orginal CONFIGRI.20 */
  785.             /* Call SysFileDelete bakconfigname */
  786.             cmdstr = '@DEL 'bakconfigname
  787.             address CMD cmdstr
  788.          end
  789.          else Do
  790.             /* rename error, try to restore original */
  791.             cmdstr = '@rename 'bakconfigname' CONFIGRI.20'
  792.             address CMD cmdstr
  793.          end
  794.       end
  795.    end
  796.    else return 4   /* file not found */
  797.    return 0
  798.  
  799.  
  800.  
  801. /* Subroutine Update_LS20_Config_20 */
  802. /* This subroutine converts a LAN Server 2.0 CONFIG.20 file to the new format */
  803. Update_LS20_Config_20:
  804.  
  805.    /* build fully qualified path names for client CONFIG.20 */
  806.    If client = 'DEFALT20' Then Do
  807.       /* DEFALT20 is special case, it must be called for each lantype */
  808.       configname = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  809.       tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20T'
  810.       bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIG20.BAK'
  811.    end
  812.    else Do
  813.       configname = rpldir'\MACHINES\'client'\CONFIG.20'
  814.       tmpconfigname = rpldir'\MACHINES\'client'\CONFIG.20T'
  815.       bakconfigname = rpldir'\MACHINES\'client'\CONFIG20.BAK'
  816.    end
  817.    /* Call SysFileDelete tmpconfigname */
  818.    Call Delete_File tmpconfigname
  819.    Call Delete_File bakconfigname
  820.  
  821.    /* determine bootdrive id from PROTSHELL statement */
  822.    do until lines(configname) = 0
  823.       data = translate(linein(configname))
  824.       If substr(data, 1, 9) = 'PROTSHELL' Then Do
  825.          ddi = pos(':\', data)
  826.          newbootdrv = substr(data,ddi - 1, 1)
  827.          Leave
  828.       end
  829.    end
  830.    Call Lineout configname     /* close file */
  831.    if newbootdrv = '' Then return 4
  832.  
  833.    /* check to see if file has already been updated with new device driver */
  834.    /* statements */
  835.    /* Call SysFileSearch '=XGA.SYS', configname, 'xgasys.' */
  836.    /* read client CONFIG.20 looking for the XGA.SYS entry */
  837.    do until lines(configname) = 0
  838.       data = translate(linein(configname))
  839.       xgasysp = pos('XGA.SYS', data)
  840.       if xgasysp <> 0 then Do
  841.          If xgasysp > 1 Then Do
  842.             prevchar = substr(data, xgasysp-1, 1)
  843.             If prevchar = '=' | prevchar = '\' Then Leave
  844.             else xgasysp = 0   /* ignore entry */
  845.          end
  846.          else xgasysp = 0   /* ignore entry */
  847.       end
  848.    end
  849.    Call Lineout configname     /* close file */
  850.    If xgasysp = 0 Then Do
  851.       /* file has not been updated, update it */
  852.       /* check to see if dd_data needs to be initialized */
  853.       If ddbootdrv <> newbootdrv Then Do
  854.          dd_data.0 = 0
  855.          ddbootdrv = newbootdrv
  856.       end
  857.       If dd_data.0 = 0 Then Do
  858.          /* initialize dd_data */
  859.          dd_data.0 = 27
  860.          dd_data.1 = 'REM Use the following 7 statements for workstations with XGA displays:'
  861.          dd_data.2 = 'REM DEVINFO=SCR,VGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  862.          dd_data.3 = 'REM DEVICE='ddbootdrv':\OS2\XGARING0.SYS'
  863.  
  864.          If basedevflag = 0 Then dd_data.4 = 'REM DEVICE='ddbootdrv':\OS2\XGA.SYS'
  865.          else dd_data.4 = 'REM BASEDEV=XGA.SYS'
  866.  
  867.          dd_data.5 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  868.          dd_data.6 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VXGA.SYS '
  869.          dd_data.7 = 'REM SET VIDEO_DEVICES=VIO_XGA'
  870.          dd_data.8 = 'REM SET VIO_XGA=DEVICE(BVHVGA,BVHXGA)'
  871.          dd_data.9 = ' '
  872.          dd_data.10 = 'REM Use the following 5 statements for workstations with 8514/A adapters:'
  873.          dd_data.11 = 'REM DEVINFO=SCR,BGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  874.          dd_data.12 = 'REM SET VIDEO_DEVICES=VIO_8514A'
  875.          dd_data.13 = 'REM SET VIO_8514A=DEVICE(BVHVGA,BVH8514A)'
  876.          dd_data.14 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  877.          dd_data.15 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\V8514A.SYS'
  878.          dd_data.16 = ' '
  879.          dd_data.17 = 'REM Use the following 4 statements for workstations with EGA displays:'
  880.          dd_data.18 = 'REM DEVINFO=SCR,EGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  881.          dd_data.19 = 'REM SET VIDEO_DEVICES=VIO_EGA'
  882.          dd_data.20 = 'REM SET VIO_EGA=DEVICE(BVHEGA)'
  883.          dd_data.21 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VEGA.SYS'
  884.          dd_data.22 = ' '
  885.          dd_data.23 = 'REM Use the following 4 statements for workstations with VGA displays:'
  886.          dd_data.24 = 'DEVINFO=SCR,VGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  887.          dd_data.25 = 'SET VIDEO_DEVICES=VIO_VGA'
  888.          dd_data.26 = 'SET VIO_VGA=DEVICE(BVHVGA)'
  889.          dd_data.27 = 'DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  890.       end
  891.  
  892.       If File_Exist(configname) = 1 Then Do
  893.          /* copy records until the DEVINFO=SCR,.. statement */
  894.          do until lines(configname) = 0
  895.             data = translate(linein(configname))
  896.             If substr(data, 1, 12) = 'DEVINFO=SCR,' Then Leave
  897.             Call Lineout tmpconfigname,data
  898.          end
  899.  
  900.          Call Lineout tmpconfigname, ' '   /* blank line */
  901.  
  902.          /* write new device driver statements to file */
  903.          do ddi= 1 to dd_data.0
  904.            Call lineout tmpconfigname, dd_data.ddi
  905.          end
  906.  
  907.          Call Lineout tmpconfigname, ' '   /* blank line */
  908.  
  909.          /* skip display records until POINTDD.SYS statement */
  910.          do until lines(configname) = 0
  911.             data = translate(linein(configname))
  912.             skip = 0
  913.             ddp1 = pos('XGARING0.SYS', data)
  914.             If ddp1 <> 0 Then skip = 1
  915.             else Do
  916.                ddp1 = pos('VXGA.SYS', data)
  917.                if ddp1 <> 0 Then skip = 1
  918.                else Do
  919.                   ddp1 = pos('VIO_XGA', data)
  920.                   if ddp1 <> 0 Then skip = 1
  921.                   else Do
  922.                      ddp1 = pos('VIO_VGA', data)
  923.                      if ddp1 <> 0 Then skip = 1
  924.                      else Do
  925.                         ddp1 = pos('VVGA.SYS', data)
  926.                         if ddp1 <> 0 Then skip = 1
  927.                         else Do
  928.                            ddp1 = pos('VGA DISPLAYS:', data)
  929.                            if ddp1 <> 0 Then skip = 1
  930.                            else Do
  931.                               ddp1 = pos('XGA DISPLAYS:', data)
  932.                               if ddp1 <> 0 Then skip = 1
  933.                            end
  934.                         end
  935.                      end
  936.                   end
  937.                end
  938.             end
  939.             If substr(data, 15, 11) = 'POINTDD.SYS' Then Leave
  940.             If skip = 0 Then Do
  941.               If data <> '' Then Call Lineout tmpconfigname, data
  942.             end
  943.          end
  944.  
  945.          Call Lineout tmpconfigname, data  /* write pointdd.sys */
  946.  
  947.          /* copy remaining records */
  948.          do until lines(configname) = 0
  949.             data = linein(configname)
  950.             Call Lineout tmpconfigname, data
  951.          end
  952.  
  953.          Call Lineout configname
  954.          Call Lineout tmpconfigname
  955.  
  956.          /* rename original CONFIG.20 */
  957.          cmdstr = '@rename 'configname' CONFIG20.BAK'
  958.          address CMD cmdstr
  959.          if rc = 0 Then Do
  960.             /* rename CONFIG.20T to be CONFIG.20 */
  961.             cmdstr = '@rename 'tmpconfigname' CONFIG.20'
  962.             address CMD cmdstr
  963.             if rc <> 0 Then Do
  964.                /* rename error, try to restore original */
  965.                cmdstr = '@rename 'bakconfigname' CONFIG.20'
  966.                address CMD cmdstr
  967.                return 4
  968.             end
  969.          end
  970.          else return 4
  971.       end
  972.    end
  973.    return 0
  974.  
  975.  
  976. /* subroutine to delete a file */
  977. Delete_File:
  978.    arg delfilename
  979.    If lines(delfilename) <> 0 Then Do
  980.       Call stream delfilename,C,'close'
  981.       cmdline = '@DEL 'delfilename
  982.       address CMD cmdline
  983.    end
  984.    else Call stream delfilename,C,'close'  /* must do a pseudo-close to prevent */
  985.                                        /* a zero length file from being created */
  986.    return 0
  987.  
  988.  
  989.  
  990. /* subroutine to display/log messages */
  991. Display_Log_Msg:
  992.    Parse Arg msgstring, parm.1, parm.2, parm.3, parm.4, parm.5, parm.6
  993.    if parm.1 <> '' Then Do
  994.       /* substitution data supplied */
  995.       startpoint = 1
  996.       newmsg = ''
  997.       sdpos = pos('%', msgstring, startpoint)
  998.       Do while sdpos <> 0
  999.          j = substr(msgstring, sdpos+1, 1)
  1000.          newmsg = newmsg || substr(msgstring, startpoint, sdpos-startpoint) || parm.j
  1001.          startpoint = sdpos+2
  1002.          sdpos = pos('%', msgstring, startpoint)
  1003.       end
  1004.       newmsg = newmsg || substr(msgstring, startpoint)
  1005.       msgstring = newmsg
  1006.    end
  1007.  
  1008.    If Logfile = '' Then Do
  1009.       /* display message locally */
  1010.       Say msgstring
  1011.    end
  1012.    else Do
  1013.       /* log message */
  1014.       Call lineout Logfile, msgstring
  1015.    end
  1016.    return 0
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022. /* subroutine to test for existance of a file */
  1023. File_Exist:
  1024.    Arg testfilename
  1025.    If lines(testfilename) = 1 Then rc = 1
  1026.    else rc = 0
  1027.    /* lines() leaves file open, must force close */
  1028.    Call stream testfilename,C,'close'
  1029.    return rc
  1030.  
  1031.  
  1032.  
  1033. Determine_RIPL_Directory:
  1034.    /* find out where IBMLAN is installed */
  1035.    os2path = value('PATH',,'OS2ENVIRONMENT')
  1036.  
  1037.    ibmlanp = pos(':\IBMLAN', translate(os2path))
  1038.    if ibmlanp = 0 Then Do
  1039.      msgdata = errprefix || message.17
  1040.      Call Display_Log_Msg msgdata, ''
  1041.      return 4
  1042.    end
  1043.  
  1044.    landrv = substr(os2path, ibmlanp-1, 1)
  1045.    lanpath = landrv':\IBMLAN'
  1046.  
  1047.    fname = lanpath'\IBMLAN.INI'
  1048.  
  1049.    /* read IBMLAN.INI looking for the RPLDIR entry */
  1050.    do until lines(fname) = 0
  1051.       data = linein(fname)
  1052.       rpldirp = pos('RPLDIR', translate(data))
  1053.       if rpldirp <> 0 then do
  1054.          rpldirp = pos('=', data)
  1055.          rpldir = strip(substr(data, rpldirp+1))
  1056.          Leave
  1057.       end
  1058.    end
  1059.    Call stream fname,C,'close'
  1060.  
  1061.    if rpldir = '' then do
  1062.       msgdata = errprefix || message.18
  1063.       Call Display_Log_Msg msgdata, ''
  1064.       return 4
  1065.    end
  1066.    return 0
  1067.  
  1068.  
  1069.  
  1070. /* subroutine to verify that the display driver id is valid */
  1071. Validate_Display_DriverID:
  1072.    /* initialize display driver ids */
  1073.    displaydrv.0 = 3
  1074.    displaydrv.1 = 'IBMVGA32'
  1075.    displaydrv.2 = 'IBMXGA32'
  1076.    displaydrv.3 = 'IBM8514'
  1077.  
  1078.    /* validate driver parameter */
  1079.    flag = 0
  1080.    Do i=1 to displaydrv.0
  1081.       If driver=displaydrv.i Then Do
  1082.          flag = 1
  1083.          leave
  1084.       end
  1085.    end
  1086.    if flag = 0 Then Do
  1087.       Call Display_Log_Msg message.19, ''
  1088.       return 4
  1089.    end
  1090.    return 0
  1091.  
  1092.  
  1093.  
  1094. /* subroutine to update client workstation record in RPL.MAP */
  1095. Update_Workstation_Record:
  1096.    rplmap = rpldir'\RPL.MAP'
  1097.    tmprplmap = rpldir'\RPLMAP.TMP'
  1098.    updateerr = 0
  1099.    Call Delete_File(tmprplmap)
  1100.    Do until lines(rplmap) = 0
  1101.       data = linein(rplmap)
  1102.       field2 = translate(word(data, 2))
  1103.       If field2 = client Then Do
  1104.          /* may be a client record, check field 4 for FIT */
  1105.          field4 = word(data,4)
  1106.          If translate(substr(field4, 1, 5)) = 'FITS\' Then Do
  1107.             /* this is the client workstation record */
  1108.             field12 = word(data, 12)
  1109.             f12p = pos(field12, data)
  1110.             ucnewos2 = translate(newOS2)
  1111.             /* determine OS type for field 12 */
  1112.             Select
  1113.                when ucnewos2 = 'OS2.20' Then os2type = '20'
  1114.                when ucnewos2 = 'OS2.20a' Then os2type = '20A'
  1115.                when ucnewos2 = 'OS2.21' Then os2type = '21'
  1116.                otherwise Do
  1117.                   os2type = ''
  1118.                   updateerr = 1
  1119.                end
  1120.             end
  1121.             If os2type <> '' Then Do
  1122.                /* update field 12 for correct OS type */
  1123.                newdata = substr(data, 1, f12p+1) || os2type
  1124.                f12p = pos('_', data, f12p+2)
  1125.                if f12p <> 0 Then newdata = newdata || substr(data, f12p)
  1126.                else Do
  1127.                     /* error, use original record */
  1128.                     newdata = data
  1129.                     updateerr = 1
  1130.                end
  1131.                data = newdata
  1132.             end
  1133.          end
  1134.       end
  1135.       Call lineout tmprplmap, data
  1136.    end
  1137.    Call lineout rplmap
  1138.    Call lineout tmprplmap
  1139.    If updateerr = 0 Then Do
  1140.       /* no error, replace RPL.MAP with new RPL.MAP */
  1141.       '@copy 'rplmap  rpldir'\RPLMAP.BAK 1>nul 2>nul'
  1142.       Call Delete_File(rplmap)
  1143.       '@rename 'tmprplmap 'RPL.MAP 1>nul 2>nul'
  1144.    end
  1145.    else Do
  1146.       /* update error, delete tmp file, return error */
  1147.       Call Delete_File(tmprplmap)
  1148.       return 4
  1149.    end
  1150.    return 0
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156. /* subroutine to read user provided response file and set keyword variables */
  1157. Read_Rspfile:
  1158.    /* read response file and get keyword values */
  1159.    clientlist.0 = 0
  1160.    Do until lines(Rspfile) = 0
  1161.       data = translate(linein(Rspfile))
  1162.       If substr(data, 1, 13) = 'DISPLAYDRIVER' Then Do
  1163.          epos = pos('=', data)
  1164.          driver = strip(substr(data, epos+1))
  1165.       end
  1166.       else If substr(data, 1, 10) = 'CLIENTLIST' | ,
  1167.               substr(data, 1, 6) = 'CLIENT' Then Do
  1168.          /* multiple CLIENT and/or CLIENTLIST entries are permitted */
  1169.          epos = pos('=', data)
  1170.          clientdata = strip(substr(data, epos+1))
  1171.          cpos = pos(',', clientdata)
  1172.          if cpos = 0 Then Do
  1173.             /* only one client specified */
  1174.             clnum = clientlist.0 + 1
  1175.             clientlist.clnum = clientdata
  1176.             clientlist.0 = clnum
  1177.          end
  1178.          else Do
  1179.             /* list of clients provided */
  1180.             startpoint = 1
  1181.             clnum = clientlist.0 + 1
  1182.             cpos = pos(',', clientdata, startpoint)
  1183.             /* scan list and put each name in clientlist array */
  1184.             Do while (cpos <> 0)
  1185.                clientlist.clnum = strip(substr(clientdata, startpoint, cpos-startpoint))
  1186.                clientlist.0 = clnum
  1187.                startpoint = cpos+1
  1188.                clnum = clnum + 1
  1189.                cpos = pos(',', clientdata, startpoint)
  1190.             end
  1191.             if startpoint < length(clientdata) Then Do
  1192.                /* last name in list */
  1193.                clientlist.clnum = strip(substr(clientdata, startpoint))
  1194.                clientlist.0 = clnum
  1195.             end
  1196.          end
  1197.       end
  1198.       else If substr(data, 1, 13) = 'CURRENTOS2DIR' Then Do
  1199.          /* optional OS/2 root directory parameter */
  1200.          epos = pos('=', data)
  1201.          currentOS2 = strip(substr(data, epos+1))
  1202.          changeOS2 = 1
  1203.       end
  1204.       else If substr(data, 1, 9) = 'NEWOS2DIR' Then Do
  1205.          /* optional OS/2 root directory parameter */
  1206.          epos = pos('=', data)
  1207.          newOS2 = strip(substr(data, epos+1))
  1208.          changeOS2 = 1
  1209.       end
  1210.    end
  1211.    Call lineout Rspfile  /* close file */
  1212.  
  1213.    /* check for required keywords */
  1214.    If driver = '' | clientlist.0 = 0 Then Do
  1215.       /* invalid/incomplete response file */
  1216.       return 4
  1217.    end
  1218.    return 0
  1219.  
  1220.  
  1221.  
  1222. /* subroutine to process command line parameters */
  1223. Process_Input_Parameters:
  1224.  
  1225.    Do i = 1 to 6
  1226.       If parm.i = '' Then Leave
  1227.       parmtype = translate(substr(parm.i,1,2))
  1228.       select
  1229.          when parmtype = '/H' Then Call Syntax_Help
  1230.  
  1231.          when parmtype = '/h' Then Call Syntax_Help
  1232.  
  1233.          when parmtype = '/D' Then Do
  1234.             if substr(parm.i, 3, 1) = ':' Then driver = substr(parm.i, 4)
  1235.             else driver = substr(parm.i, 3)
  1236.             driver = translate(driver)
  1237.          end
  1238.  
  1239.          when parmtype = '/C' Then Do
  1240.             if substr(parm.i, 3, 1) = ':' Then clientdata = substr(parm.i, 4)
  1241.             else clientdata = substr(parm.i, 3)
  1242.             clientdata = translate(clientdata)
  1243.             cpos = pos(',', clientdata)
  1244.             if cpos = 0 Then Do
  1245.                clientlist.0 = 1
  1246.                clientlist.1 = clientdata
  1247.             end
  1248.             else Do
  1249.                /* list of clients provided */
  1250.                startpoint = 1
  1251.                clnum = 1
  1252.                cpos = pos(',', clientdata, startpoint)
  1253.                /* scan list and put each name in clientlist array */
  1254.                Do while (cpos <> 0)
  1255.                   clientlist.clnum = substr(clientdata, startpoint, cpos-startpoint)
  1256.                   clientlist.0 = clnum
  1257.                   startpoint = cpos+1
  1258.                   clnum = clnum + 1
  1259.                   cpos = pos(',', clientdata, startpoint)
  1260.                end
  1261.                if startpoint < length(clientdata) Then Do
  1262.                   /* last name in list */
  1263.                   clientlist.clnum = substr(clientdata, startpoint)
  1264.                   clientlist.0 = clnum
  1265.                end
  1266.             end
  1267.          end
  1268.  
  1269.          when parmtype = '/O' Then Do
  1270.             if substr(parm.i, 3, 1) = ':' Then currentOS2 = substr(parm.i, 4)
  1271.             else currentOS2 = substr(parm.i, 3)
  1272.             changeOS2 = 1
  1273.          end
  1274.  
  1275.          when parmtype = '/N' Then Do
  1276.             if substr(parm.i, 3, 1) = ':' Then newOS2 = substr(parm.i, 4)
  1277.             else newOS2 = substr(parm.i, 3)
  1278.             changeOS2 = 1
  1279.          end
  1280.  
  1281.          when parmtype = '/L' Then Do
  1282.             if substr(parm.i, 3, 1) = ':' Then Logfile = substr(parm.i, 4)
  1283.             else Logfile = substr(parm.i, 3)
  1284.          end
  1285.  
  1286.          when parmtype = '/R' Then Do
  1287.             if substr(parm.i, 3, 1) = ':' Then Rspfile = substr(parm.i, 4)
  1288.             else Rspfile = substr(parm.i, 3)
  1289.          end
  1290.  
  1291.          otherwise Do
  1292.            msgdata = errprefix || message.20
  1293.            Call Display_Log_Msg msgdata, parm.i
  1294.            return 4
  1295.          end
  1296.       end
  1297.    end
  1298.    return 0
  1299.  
  1300.  
  1301.  
  1302. Determine_Installed_OS2_Levels:
  1303.    syslevel = '\OS2\INSTALL\SYSLEVEL.OS2'
  1304.    If File_Exist(rpldir'\OS2'syslevel) = 1 Then os213 = 1
  1305.    else os213 = 0
  1306.  
  1307.    If File_Exist(rpldir'\OS2.20'syslevel) = 1 Then os220 = 1
  1308.    else os220 = 0
  1309.  
  1310.    If File_Exist(rpldir'\OS2.20a'syslevel) = 1 Then os220a = 1
  1311.    else os220a = 0
  1312.  
  1313.    If File_Exist(rpldir'\OS2.21'syslevel) = 1 Then os221 = 1
  1314.    else os221 = 0
  1315.    return
  1316.  
  1317.  
  1318. /* Subroutine Syntax_Help */
  1319. /* This subroutine displays the syntax help panel. */
  1320. Syntax_Help:
  1321.   If Logfile = '' Then Do
  1322.      Do i = 30 to 34
  1323.         Call Display_Log_Msg message.i, ''
  1324.      end
  1325.      Call Display_Log_Msg message.22, ''
  1326.      Pull dummy
  1327.  
  1328.      Do i = 35 to 37
  1329.         Call Display_Log_Msg message.i, ''
  1330.      end
  1331.      Call Display_Log_Msg message.22, ''
  1332.      Pull dummy
  1333.  
  1334.      Call Display_Log_Msg message.38, ''
  1335.      exit
  1336.   end
  1337.   else Do
  1338.      Call Display_Log_Msg message.21, p1, p2, p3, p4, p5, p6
  1339.      Call Error_Exit
  1340.   end
  1341.  
  1342.  
  1343. Initialize_NLS_Messages:
  1344. /***********************************************************************/
  1345. /*                            NLS messages                             */
  1346. /*                                                                     */
  1347. /* The following message strings should be translated for NLS support. */
  1348. /*                                                                     */
  1349. /* Note: The %1, %2, etc. strings represent dynamic data fields that   */
  1350. /*       are filled in when the message is displayed.  Do not          */
  1351. /*       translate the %1, %2, etc. fields.                            */
  1352. /*       The 'CRLF,' sequence that ends some lines represents          */
  1353. /*       formatting control (new line) and should not be translated.   */
  1354. /*       However, after translation, each message may need to be       */
  1355. /*       manually reformatted to prevent excessive lenght message      */
  1356. /*       lines. The message display code does not automatically        */
  1357. /*       reformat long message lines.                                  */
  1358. /***********************************************************************/
  1359. arg message_type
  1360.  
  1361. errprefix = 'ERROR: '
  1362. unknown = 'UNKNOWN'
  1363.  
  1364. /* start of error and informational messages */
  1365. message.1 = 'Missing keyword in '
  1366. message.2 = '       Displaydriver, Client or Clientlist, and Logfile are required.'
  1367. message.3 = 'HISTORY LOG: '
  1368. message.4 = 'Unable to open the Logfile '
  1369. message.5 = 'The display driver %1.DLL is not installed in the Remote IPL' CRLF,
  1370.             '      directory %2.'
  1371. message.6 = ''
  1372. message.7 = 'Error detected.  Check log file: '
  1373. message.8 = 'The version of LAN Server is prior to Version 2.0.'
  1374. message.9 = 'The version of OS/2 in the %1 directory tree is' CRLF,
  1375.             '      %2.  This version of OS/2 does not support 32 bit display drivers.' CRLF,
  1376.             '      Processing is being terminated.'
  1377. message.10 = ' copy of OS2INI.20 was updated.'
  1378. message.11 = ' copy of CONFIG.20 was updated.'
  1379.  
  1380. message.12 = ' copy of CONFIG.20 was not updated.'
  1381. message.13 = '.FIT was updated.'
  1382. message.14 = '.FIT was not updated.'
  1383. message.15 = ' copy of OS2INI.20 was not updated.  Either the file did' CRLF,
  1384.              '      not exist or the Remote client is still powered up and has the' CRLF,
  1385.              '      file locked.  Processing terminated for '
  1386. message.16 = 'Not able to upgrade the format of file %1\IBMCOM\%2\CONFIG.20.'
  1387. message.17 = 'The PATH environment variable does not contain a reference to' CRLF,
  1388.              '      \IBMLAN.  Either LAN Server 2.0 is not installed or the PATH' CRLF,
  1389.              '      variable has been modified to remove \IBMLAN references.  If' CRLF,
  1390.              '      LAN Server 2.0 is installed, use the SET command to update the' CRLF,
  1391.              '      PATH variable to specify the path for the directory \IBMLAN\NETPROG' CRLF,
  1392.              '      and then rerun RPLSETD.CMD.'
  1393. message.18 = 'RPLDIR parameter was not found in IBMLAN.INI.'
  1394. message.19 = 'Invalid display driver specified.'
  1395. message.20 = 'The option %1 is not a valid option.'
  1396. message.21 = 'The following RPLSETD command syntax is not valid:' CRLF,
  1397.              '      RPLSETD  %1 %2 %3 %4 %5 %6'
  1398. message.22 = CRLF 'Press the Enter key for next screen.'
  1399. message.23 = 'The RPLMIG21.CMD procedure has not been run to upgrade Remote IPL' CRLF,
  1400.              'to support OS/2 2.1.  Run RPLMIG21.CMD prior to using RPLSETD.CMD.'
  1401. message.24 = ''
  1402. message.25 = ' copy of CONFIGRI.20 was updated.'
  1403. message.26 = ' copy of CONFIGRI.20 not was updated.'
  1404. message.27 = ' workstation record in RPL.MAP was updated.'
  1405. message.28 = ' workstation record in RPL.MAP could not be updated.'
  1406.  
  1407. /* start of syntax help messages */
  1408. message.30 = 'RPLSETD   [/H]  [ /D:driver  /C:client[,client2,client3,...] ] ' CRLF,
  1409.              '          [/O:current_OS2]  [/N:new_OS2] [/L:Logfile]   [/R:Response_file]'
  1410. message.31 = '    where /H is a request for this help panel.  If specified, it must'CRLF,
  1411.              '             be first parameter.'
  1412. message.32 = '          /D:driver (DISPLAYDRIVER) is the new display type for the client' CRLF,
  1413.              '                 definition.  The following display types are valid:' CRLF,
  1414.              '                   IBMVGA32  - 32 bit VGA display driver' CRLF,
  1415.              '                   IBMXGA32  - 32 bit XGA display driver' CRLF,
  1416.              '                   IBM8514   - 16 bit 8514 display driver'
  1417. message.33 = '          /C:client (CLIENT or CLIENTLIST) is the name of one or more OS/2' CRLF,
  1418.              '                 Remote IPL client workstations.  If more than one client is'CRLF,
  1419.              '                 specified, each client name must be separated with a comma.'CRLF,
  1420.              '                 Imbedded blanks are not allowed.  Multiple CLIENT and/or'CRLF,
  1421.              '                 CLIENTLIST parameters are allowed in the response file.'
  1422. message.34 = '          /O:current_OS2 (CURRENTOS2DIR) is the root directory (under' CRLF,
  1423.              '                 \IBMLAN\RPL) for the current OS/2 2.0 operating system that' CRLF,
  1424.              '                 the client is booting.  This parameter is case sensitive.' CRLF,
  1425.              '                 The default is OS2.20.  /O or /N should only be specified' CRLF,
  1426.              '                 when the version of the client operating system should be' CRLF,
  1427.              '                 changed.'
  1428. message.35 = '          /N:new_OS2 (NEWOS2DIR) is the root directory (under \IBMLAN\RPL) for' CRLF,
  1429.              '                 the OS/2 2.0 operating system that the client is to be' CRLF,
  1430.              '                 switched to.  This parameter is case sensitive.  The default' CRLF,
  1431.              '                 is OS2.21.  /O or /N should only be specified when the' CRLF,
  1432.              '                 version of the client operating system should be changed.'
  1433. message.36 = '          /L:Logfile is the fully qualified name of a file to ' CRLF,
  1434.              '                  which all messages and errors are to be logged.  If' CRLF,
  1435.              '                  logfile is specified, no messages or errors will be' CRLF,
  1436.              '                  displayed on the screen.'
  1437. message.37 = '          /R:Response_file is the fully qualified name of a file' CRLF,
  1438.              '                  that contains all the inputs in keyword form(Keyword=value).'CRLF,
  1439.              '                  The keywords are indicated above in () following the /X:' CRLF,
  1440.              '                  syntax.  If this parameter is specified, all other command' CRLF,
  1441.              '                  line parameters except Logfile are ignored.  It is' CRLF,
  1442.              '                  recommended that the Logfile parameter be specfied whenever' CRLF,
  1443.              '                  the Response_file parameter is used.'
  1444. message.38 = '    Note: The following conditions must be meet before running RPLSETD:' CRLF,
  1445.              '          1. The Remoteboot Service should be stopped.' CRLF,
  1446.              '          2. The Remote IPL workstations to be upgraded must do a' CRLF,
  1447.              '             System Shutdown.'CRLF,
  1448.              '          3. Remote IPL workstations to be upgraded can not have a session' CRLF,
  1449.              '             with the RIPL server.  If necessary, force the session to' CRLF,
  1450.              '             disconnect using the server full screen interface. '
  1451. return
  1452.